home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / tls / tls074c.sunsparc.Z / tls074c.sunsparc / lib / vtcl / examples / findcmd.tcl < prev    next >
Encoding:
Text File  |  1995-07-20  |  2.3 KB  |  91 lines

  1. #!/bin/vtcl
  2. #  This is the complete application that appeared in the 
  3. #  SCOWorld Magazine, April 1995...
  4.  
  5. # This callback disconnects the script from the Visual Tcl 
  6. # display engine;  then exits the vtcl interpreter.  
  7. # All callbacks receive widget info via a parameter, but 
  8. # we'll ignore it here.
  9. proc CloseCB {cbs} {
  10.     VtClose
  11.     exit 0
  12. }
  13.  
  14. # Using the widget name of the radio box, grab the
  15. # short name to determine the minimum file size.
  16. # Return that value.
  17. proc GetMinFileSize {} {
  18.     global rbox
  19.     set toggleWidget [VtGetValues $rbox -value]
  20.     return [VxGetShortName $toggleWidget]
  21. }
  22.  
  23. # Exec the find command to grab a list of files that
  24. # exceeds the minimum file size indicated by the user.
  25. # Update the list widget with the file list when the 
  26. # find command is completed.
  27. proc PerformFindCB {cbs} {
  28.     global listW
  29.     set sizeValue [GetMinFileSize]    
  30.  
  31.     # Turn the cursor into a watch to prevent the user
  32.     # from pushing more buttons during the execution of find.
  33.     #
  34.     VtLock
  35.     set result [exec find [pwd] -type f -size +${sizeValue} -print]
  36.     VtUnLock
  37.  
  38.     # Post a message if there are no files larger
  39.     # than sizeValue located.
  40.     if { [llength $result] == 0 } {
  41.         set parentDialog [keylget cbs dialog]
  42.         set infoForm [VtInformationDialog $parentDialog.infoForm \
  43.             -message "No Files Found" \
  44.             -ok \
  45.             ]
  46.         VtShow $infoForm
  47.     }
  48.     VtSetValues $listW -itemList $result
  49. }
  50.  
  51. # Connect to the Visual Tcl display engine.
  52. set app [VtOpen findtool]
  53.  
  54. # Build the main dialog.
  55. # (the -cancelButton maps one of the dialog buttons to the Escape key)
  56. set dlog [VtFormDialog $app.dlog \
  57.     -title "The Find Tool" \
  58.     -okLabel "Begin Find" \
  59.     -okCallback PerformFindCB \
  60.     -wmCloseCallback CloseCB \
  61.     -cancelCallback CloseCB \
  62.     -cancelLabel Quit \
  63.     -cancelButton CANCEL \
  64.     ]
  65.  
  66. set listW [VtList $dlog.list \
  67.     -rows 10 \
  68.     -bottomSide FORM \
  69.     ]
  70.  
  71. set labelW [VtLabel $dlog.label \
  72.     -label "Minimum Fize Sizes\nto Search" \
  73.     -leftSide $listW \
  74.     -alignTop $listW \
  75.     -rightSide FORM \
  76.     ]
  77. set rbox [VtRadioBox $dlog.rbox \
  78.     -topSide $labelW \
  79.     -leftSide $listW \
  80.     -rightSide FORM \
  81.     ]
  82.  
  83. # Create the size options to list inside the radio box.
  84. # Compensate for the 512K blocks size conversion.
  85. VtToggleButton $rbox.200K -label "100 K" 
  86. VtToggleButton $rbox.1000K -label "500 K"
  87. VtToggleButton $rbox.2000K -label "1 Megabyte" -set 1
  88.  
  89. VtShow $dlog
  90. VtMainLoop
  91.